<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>图片样式</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    html,
    body {
        width: 100%;
        height: 100%;
    }

    .box {
        border: 1px solid black;
        margin: auto;
        width: 200px;
        height: 200px;
    }
    .box img{
        width: 100%;
        height: 100%;
    }
    .img1{
        object-fit: fill;
    }
    .img2{
        object-fit: contain;
    }
    .img3{
        object-fit: cover;
    }
    .img4{
        object-fit: none;
    }
    .img5{
        object-fit: scale-down;
    }
</style>

<body>
    <div class="box">
        <img src="./img/demo.jpg" alt="">
    </div>
    <div class="box">
        <img src="./img/demo.jpg" alt="" class="img1">
    </div>
    <div class="box">
        <img src="./img/demo.jpg" alt="" class="img2">
    </div>
    <div class="box">
        <img src="./img/demo.jpg" alt="" class="img3">
    </div>
    <div class="box">
        <img src="./img/demo.jpg" alt="" class="img4">
    </div>
    <div class="box">
        <img src="./img/demo.jpg" alt="" class="img5">
    </div>
</body>
<script type="text/javascript">
</script>

</html>